package com.fhz.mvvmshopjava.di;

import android.content.Context;

import com.fhz.mvvmshopjava.dao.UserDao;
import com.fhz.mvvmshopjava.utils.ACache;
import com.fhz.mvvmshopjava.utils.MyDatabase;
import com.fhz.mvvmshopjava.utils.UserManager;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import dagger.hilt.InstallIn;
import dagger.hilt.android.qualifiers.ApplicationContext;
import dagger.hilt.components.SingletonComponent;

/**
 * 时间:2022/5/31
 *
 * @author msfeng
 * 简述: TODO
 */
@Module
@InstallIn(SingletonComponent.class)
public class UserModule {

    @Singleton
    @Provides
    public MyDatabase getMyDatabase(@ApplicationContext Context context){
        return MyDatabase.getMyDatabase(context);
    }

    @Provides
    public UserDao getUserDao(MyDatabase myDatabase){
        return myDatabase.userDao();
    }

    @Singleton
    @Provides
    public UserManager getACache(@ApplicationContext Context context){
        return UserManager.getInstance(context);
    }
}

